package com.by.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.by.constant.SysRoleConstants;
import com.by.entity.SysRole;
import com.by.service.SysRoleService;
import com.by.mapper.SysRoleMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 86176
 * @description 针对表【sys_role(角色)】的数据库操作Service实现
 * @createDate 2024-12-09 14:54:02
 */

/**
 * 查询系统角色列表属于全量数据查询，一般情况项目对于全量查询的数据需要进行缓存处理
 */
@Service
@CacheConfig(cacheNames = "com.by.service.impl.SysRoleServiceImpl")
public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole>
        implements SysRoleService {

    @Autowired
    private SysRoleMapper sysRoleMapper;

    @Override
    @Cacheable(key = SysRoleConstants.ALL_ROLES)
    public List<SysRole> queryAllSysRoleList() {
        return sysRoleMapper.selectList(new LambdaQueryWrapper<SysRole>()
                .orderByDesc(SysRole::getCreateTime)
        );
    }
}




